package com.yj.service;

import com.yj.entity.ChatContent;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class StringMessageHandlerProcess implements MessageHandlerProcess {


    @Autowired
    private ChatService qytwChatService;

    public StringMessageHandlerProcess() {

    }

    @Override
    public boolean support(Object message) {
        return String.class.isAssignableFrom(message.getClass());
    }

    @Override
    public ChatContent process(Object message) {
        log.info("Process message Type: String, messsage:" + message);
        ChatContent chatContent =  qytwChatService.chat((String) message);
        return chatContent;
    }
}
